# Create your views here.
from client import client
from django import forms
from django.shortcuts import render_to_response
from django.utils.translation import ugettext as _

class whoisForm(forms.Form):
  domain = forms.CharField(_("Domain name"))
  def query(self):
    cl = client()
    return cl.query(self.cleaned_data['domain'])
def query(request):
  if('domain' in request.GET):
    form = whoisForm(request.GET)
    if(form.is_valid()):
      return render_to_response("whois/response.html", {'form' : form, 'response' : form.query()})
    else:
      return render_to_response("whois/query.html", {"form" : form})
  else:
    form = whoisForm()
    return render_to_response("whois/query.html", {"form" : form})	